<%@ page import="java.sql.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>saveUpdateToCart</title>
</head>
<%
request.setCharacterEncoding("UTF-8");
String meal_name = request.getParameter("meal_name");
String order_num = request.getParameter("order_num");
String cooker_name = request.getParameter("customer_name");
String restaurant_name = request.getParameter("restaurant_name");

try {
    Class.forName("org.mariadb.jdbc.Driver");
    try (Connection conn = DriverManager.getConnection("jdbc:mariadb://localhost:3306/mealdb?user=root&password=1230321");
         PreparedStatement pstmt = conn.prepareStatement("UPDATE meal_detail SET active = ? WHERE name = ? ")) {

        pstmt.setString(1, "充足");
        pstmt.setString(2, meal_name);
        //pstmt.setString(3, order_num);


        int rowsUpdated = pstmt.executeUpdate();
        if (rowsUpdated > 0) {
            out.println("更新成功！");
        } else {
            out.println("更新失败！");
        }
        response.sendRedirect("kitchenIndex.jsp?customer_name="+cooker_name+"&restaurant_name="+restaurant_name);
    } catch (SQLException e) {
        out.println("数据库操作错误：" + e.getMessage());
    }
} catch (ClassNotFoundException e) {
    out.println("数据库驱动加载失败：" + e.getMessage());
}

%>
</body>
</html>